﻿namespace HRM.CORE.Process
{
    using DevExpress.Data;
    using DevExpress.Utils;
    using DevExpress.XtraBars;
    using DevExpress.XtraBars.Docking;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraGrid;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Menu;
    using DevExpress.XtraGrid.Views.BandedGrid;
    using DevExpress.XtraGrid.Views.Base;
    using DevExpress.XtraGrid.Views.Grid;
    using DevExpress.XtraGrid.Views.Grid.ViewInfo;
    using APP.HELPER;
    using Common.Base;
    using Common.Class; using APP.HELPER.Utils.Language; using Security.Security; using Dictionary.ERP;
    using Common.Report;
    using HRM.CORE;
    using HRM.CORE.REPORT;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms; using Common;
    using Security.ERP;

    public class xucPetition : Common.Base.XucBaseBasicB
    {
        private BandedGridColumn colBranchName;
        private BandedGridColumn colDepartmentName;
        private BandedGridColumn colDescription;
        private BandedGridColumn colEmployeeCode;
        private BandedGridColumn colFirstName;
        private BandedGridColumn colGroupName;
        private BandedGridColumn colLastName;
        private BandedGridColumn colPetitionID;
        private BandedGridColumn colReason;
        private BandedGridColumn colReasonCannot;
        private BandedGridColumn colRestFromDate;
        private BandedGridColumn colRestToDate;
        private BandedGridColumn colStatus;
        private BandedGridColumn colSymbol;
        private BandedGridColumn colWriteDate;
        private BandedGridColumn colWriteFromDate;
        private BandedGridColumn colWriteToDate;
        private IContainer components;
        private DockManager dm;
        private BandedGridView gbList;
        private GridControl gcList;
        private GridBand gridBand1;
        private GridBand gridBand2;
        private GridBand gridBand3;
        private GridBand gridBand5;
        private GridBand gridBand7;
        private GridBand gridBand8;
        private GridBand gridBand9;
        private System.DateTime m_BeginDate;
        private string m_EmployeeCode;
        private System.DateTime m_EndDate;
        private int m_IndexKey;
        private RepositoryItemCalcEdit repCal;
        private RepositoryItemImageComboBox repStatus;

        public event ItemSelectedEventHander ItemSelected;

        public xucPetition()
        {
            this.components = null;
            this.m_EmployeeCode = "";
            this.m_IndexKey = 0;
            this.m_BeginDate = System.DateTime.Now;
            this.m_EndDate = System.DateTime.Now;
            this.InitializeComponent();
            if (base.ParentForm != null)
            {
                this.dm.Form = base.ParentForm;
            }
            this.Init();
            base.ucToolBar.bm.SetPopupContextMenu(this.gcList, base.ucToolBar.pm);
            base.ucToolBar.bbiHistory.Visibility = BarItemVisibility.Always;
            base.ucToolBar.bbiUtils.Visibility = BarItemVisibility.Always;
            base.ucToolBar.bbiGroup.Visibility = BarItemVisibility.Always;
            base.ucToolBar.bbiMerge.Visibility = BarItemVisibility.Always;
            base.ucToolBar.bbiChangeId.Visibility = BarItemVisibility.Always;
            base.ucToolBar.bbiEditUnitConvret.Visibility = BarItemVisibility.Always;
        }

        public xucPetition(string EmployeeCode)
        {
            this.components = null;
            this.m_EmployeeCode = "";
            this.m_IndexKey = 0;
            this.m_BeginDate = System.DateTime.Now;
            this.m_EndDate = System.DateTime.Now;
            this.InitializeComponent();
            this.m_EmployeeCode = EmployeeCode;
            base.ucToolBar.SetInterface();
        }

        protected override void Add()
        {
            if (this.m_EmployeeCode == "")
            {
                MessageBox.Show("Vui l\x00f2ng chọn nh\x00e2n vi\x00ean ở tr\x00ean!");
            }
            else
            {
                xfmPetitionAdd add = new xfmPetitionAdd(Actions.Add, this.m_EmployeeCode);
                add.Added += new xfmPetitionAdd.AddedEventHander(this.frm_Added);
                add.ShowDialog();
            }
        }

        public override void Change()
        {
            if (MyRule.IsAccess("bbiProcessPetition"))
            {
                HRM_PROCESS_PETITION item = new HRM_PROCESS_PETITION();
                object focusedRowCellValue = this.gbList.GetFocusedRowCellValue("PetitionID");
                if (focusedRowCellValue != null)
                {
                    base.SetWaitDialogCaption("Đang kiểm tra dữ liệu....");
                    if (item.Get(new Guid(focusedRowCellValue.ToString())) != "OK")
                    {
                        this.DoHide();
                        XtraMessageBox.Show("Dữ liệu kh\x00f4ng tồn tại", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        this.DoHide();
                        xfmPetitionAdd add = new xfmPetitionAdd(Actions.Update, item);
                        add.Updated += new xfmPetitionAdd.UpdatedEventHander(this.frm_Updated);
                        add.Added += new xfmPetitionAdd.AddedEventHander(this.frm_Added);
                        add.ShowDialog();
                    }
                }
            }
        }

        public override void Delete()
        {
            if (MyRule.IsDelete("bbiProcessPetition"))
            {
                bool flag = false;
                int[] selectedRows = this.gbList.GetSelectedRows();
                if (XtraMessageBox.Show("Bạn c\x00f3 muốn x\x00f3a kh\x00f4ng?", "Th\x00f4ng b\x00e1o", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.No)
                {
                    string str;
                    object rowCellValue;
                    base.SetWaitDialogCaption("Đang x\x00f3a...");
                    HRM_PROCESS_PETITION hrm_process_petition = new HRM_PROCESS_PETITION();
                    for (int i = selectedRows.Length; i > 0; i--)
                    {
                        flag = true;
                        rowCellValue = this.gbList.GetRowCellValue(selectedRows[i - 1], "PetitionID");
                        if (rowCellValue != null)
                        {
                            SYS_LOG.Insert("Đơn Xin Nghỉ Ph\x00e9p", "Xo\x00e1", rowCellValue.ToString());
                            str = hrm_process_petition.Delete(new Guid(rowCellValue.ToString()));
                            if (str == "OK")
                            {
                                this.gbList.DeleteRow(selectedRows[i - 1]);
                            }
                            else if (str != "OK")
                            {
                                MessageBox.Show("Th\x00f4ng tin kh\x00f4ng được x\x00f3a\r\n" + str, "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                            }
                        }
                    }
                    this.DoHide();
                    if (!flag && (hrm_process_petition.GetList().Rows.Count != 0))
                    {
                        rowCellValue = this.gbList.GetFocusedRowCellValue("PetitionID");
                        if (rowCellValue != null)
                        {
                            SYS_LOG.Insert("Đơn Xin Nghỉ Ph\x00e9p", "Xo\x00e1", rowCellValue.ToString());
                            base.SetWaitDialogCaption("Đang x\x00f3a...");
                            str = hrm_process_petition.Delete(new Guid(rowCellValue.ToString()));
                            if (str == "OK")
                            {
                                this.gbList.DeleteRow(this.gbList.FocusedRowHandle);
                            }
                            else if (str != "OK")
                            {
                                MessageBox.Show("Th\x00f4ng tin kh\x00f4ng được x\x00f3a\r\n" + str, "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                            }
                            this.DoHide();
                        }
                    }
                }
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        protected void DoShowMenu(GridHitInfo hi)
        {
            if (hi.HitTest == GridHitTest.ColumnButton)
            {
                GridViewMenu menu = new GridViewColumnButtonMenu(this.gbList);
                menu.Init(hi);
                menu.Show(hi.HitPoint);
            }
        }

        protected override bool ExportPermision()
        {
            base._exportView = this.gbList;
            if (!MyRule.IsExport("bbiProcessPetition"))
            {
                return false;
            }
            SYS_LOG.Insert("Đơn Xin Nghỉ Ph\x00e9p", "Xuất");
            return base.ExportPermision();
        }

        private void frm_Added(object sender, HRM_PROCESS_PETITION Item)
        {
            this.ReLoad();
        }

        private void frm_Updated(object sender, HRM_PROCESS_PETITION Item)
        {
            this.ReLoad();
        }

        private void gbList_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
        {
            if (e.RowHandle == -2147483648)
            {
                e.Handled = true;
                e.Painter.DrawObject(e.Info);
                Rectangle bounds = e.Bounds;
                e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(0x3f, 0xa5, 0xa5, 0)), bounds);
                bounds.Height--;
                bounds.Width--;
                e.Graphics.DrawRectangle(Pens.Blue, bounds);
            }
            int rowHandle = e.RowHandle;
            if (rowHandle >= 0)
            {
                rowHandle++;
                e.Info.DisplayText = rowHandle.ToString();
            }
        }

        private void gbList_DoubleClick(object sender, EventArgs e)
        {
            if (this.gbList.RowCount != 0)
            {
                this.Change();
            }
        }

        private void gbList_KeyDown(object sender, KeyEventArgs e)
        {
            this.ucList_ListKeyDown(sender, e);
            if ((e.KeyCode == Keys.Delete) && (this.gbList.RowCount != 0))
            {
                this.Delete();
                this.SetMenu(null);
            }
        }

        private void gbList_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.DoShowMenu(this.gbList.CalcHitInfo(new Point(e.X, e.Y)));
            }
            this.SetMenu(null);
        }

        private void gbList_RowCellClick(object sender, RowCellClickEventArgs e)
        {
            Common.Class.RowClickEventArgs ex = new Common.Class.RowClickEventArgs(e.RowHandle, e.Column.ColumnHandle);
            this.ItemSelectd(ex);
            this.SetMenu(ex);
            this.SetSearch(ex);
        }

        private void Init()
        {
            MyRule.Check("bbiProcessPetition");
            base.ucToolBar.bbiPrint.Visibility = MyRule.Printed;
            base.ucToolBar.bbiExport.Visibility = MyRule.Exported;
            base.ucToolBar.bbiAdd.Visibility = MyRule.Added;
            base.ucToolBar.bbiDelete.Visibility = MyRule.Deleted;
            base.ucToolBar.bbiEdit.Visibility = MyRule.Edited;
            base.RibbonBar.Add.Visibility = MyRule.Added;
            base.RibbonBar.Change.Visibility = MyRule.Edited;
            base.RibbonBar.Delete.Visibility = MyRule.Deleted;
            base.RibbonBar.Print.Visibility = MyRule.Printed;
            base.RibbonBar.Export.Visibility = MyRule.Exported;
            base.RibbonBar.Import.Visibility = MyRule.Imported;
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            StyleFormatCondition condition = new StyleFormatCondition();
            StyleFormatCondition condition2 = new StyleFormatCondition();
            this.colStatus = new BandedGridColumn();
            this.repStatus = new RepositoryItemImageComboBox();
            this.dm = new DockManager(this.components);
            this.gcList = new GridControl();
            this.gbList = new BandedGridView();
            this.gridBand2 = new GridBand();
            this.colEmployeeCode = new BandedGridColumn();
            this.colFirstName = new BandedGridColumn();
            this.colLastName = new BandedGridColumn();
            this.colBranchName = new BandedGridColumn();
            this.colDepartmentName = new BandedGridColumn();
            this.colGroupName = new BandedGridColumn();
            this.gridBand9 = new GridBand();
            this.colWriteDate = new BandedGridColumn();
            this.gridBand3 = new GridBand();
            this.colWriteFromDate = new BandedGridColumn();
            this.colWriteToDate = new BandedGridColumn();
            this.gridBand5 = new GridBand();
            this.gridBand8 = new GridBand();
            this.colRestFromDate = new BandedGridColumn();
            this.colRestToDate = new BandedGridColumn();
            this.gridBand7 = new GridBand();
            this.colSymbol = new BandedGridColumn();
            this.colReason = new BandedGridColumn();
            this.gridBand1 = new GridBand();
            this.colReasonCannot = new BandedGridColumn();
            this.colDescription = new BandedGridColumn();
            this.colPetitionID = new BandedGridColumn();
            this.repCal = new RepositoryItemCalcEdit();
            this.repStatus.BeginInit();
            this.dm.BeginInit();
            this.gcList.BeginInit();
            this.gbList.BeginInit();
            this.repCal.BeginInit();
            base.SuspendLayout();
            base.ucToolBar.Size = new Size(0x2e8, 0x2b);
            this.colStatus.Caption = "Trạng th\x00e1i";
            this.colStatus.ColumnEdit = this.repStatus;
            this.colStatus.FieldName = "Status";
            this.colStatus.Name = "colStatus";
            this.colStatus.OptionsColumn.AllowEdit = false;
            this.colStatus.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colStatus.Visible = true;
            this.colStatus.Width = 0x5f;
            this.repStatus.AutoHeight = false;
            this.repStatus.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.repStatus.Items.AddRange(new ImageComboBoxItem[] { new ImageComboBoxItem("Chờ duyệt", 0, -1), new ImageComboBoxItem("Đ\x00e3 duyệt", 1, -1), new ImageComboBoxItem("Kh\x00f4ng được duyệt", 2, -1) });
            this.repStatus.Name = "repStatus";
            this.dm.DockModeVS2005FadeSpeed = 0x3e8;
            this.dm.TopZIndexControls.AddRange(new string[] { "DevExpress.XtraBars.BarDockControl", "DevExpress.XtraBars.StandaloneBarDockControl", "System.Windows.Forms.StatusBar", "DevExpress.XtraBars.Ribbon.RibbonStatusBar", "DevExpress.XtraBars.Ribbon.RibbonControl" });
            this.gcList.Dock = DockStyle.Fill;
            this.gcList.EmbeddedNavigator.Buttons.Append.Visible = false;
            this.gcList.EmbeddedNavigator.Buttons.CancelEdit.Visible = false;
            this.gcList.EmbeddedNavigator.Buttons.Edit.Visible = false;
            this.gcList.EmbeddedNavigator.Buttons.EndEdit.Visible = false;
            this.gcList.EmbeddedNavigator.Buttons.Remove.Visible = false;
            this.gcList.EmbeddedNavigator.TextStringFormat = "{0}/{1}";
            this.gcList.Location = new Point(0, 0x2b);
            this.gcList.MainView = this.gbList;
            this.gcList.Name = "gcList";
            this.gcList.RepositoryItems.AddRange(new RepositoryItem[] { this.repCal, this.repStatus });
            this.gcList.Size = new Size(0x2e8, 0x1d4);
            this.gcList.TabIndex = 6;
            this.gcList.UseEmbeddedNavigator = true;
            this.gcList.ViewCollection.AddRange(new BaseView[] { this.gbList });
            this.gbList.Appearance.GroupRow.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.gbList.Appearance.GroupRow.Options.UseFont = true;
            this.gbList.Appearance.HeaderPanel.Options.UseTextOptions = true;
            this.gbList.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center;
            this.gbList.Appearance.HeaderPanel.TextOptions.WordWrap = WordWrap.Wrap;
            this.gbList.Bands.AddRange(new GridBand[] { this.gridBand2, this.gridBand9, this.gridBand3, this.gridBand5, this.gridBand8, this.gridBand7, this.gridBand1 });
            this.gbList.ColumnPanelRowHeight = 0x20;
            this.gbList.Columns.AddRange(new BandedGridColumn[] { 
                this.colPetitionID, this.colEmployeeCode, this.colFirstName, this.colLastName, this.colBranchName, this.colDepartmentName, this.colGroupName, this.colWriteDate, this.colWriteFromDate, this.colWriteToDate, this.colRestFromDate, this.colRestToDate, this.colSymbol, this.colReason, this.colStatus, this.colReasonCannot, 
                this.colDescription
             });
            this.gbList.FixedLineWidth = 1;
            this.gbList.FocusRectStyle = DrawFocusRectStyle.RowFocus;
            condition.Appearance.ForeColor = Color.DarkGreen;
            condition.Appearance.Options.UseForeColor = true;
            condition.ApplyToRow = true;
            condition.Column = this.colStatus;
            condition.Condition = FormatConditionEnum.Equal;
            condition.Value1 = "1";
            condition2.Appearance.ForeColor = Color.Red;
            condition2.Appearance.Options.UseForeColor = true;
            condition2.ApplyToRow = true;
            condition2.Column = this.colStatus;
            condition2.Condition = FormatConditionEnum.Equal;
            condition2.Value1 = "2";
            this.gbList.FormatConditions.AddRange(new StyleFormatCondition[] { condition, condition2 });
            this.gbList.GridControl = this.gcList;
            this.gbList.GroupPanelText = "K\x00e9o v\x00e0 Thả cột v\x00e0o đ\x00e2y để nh\x00f3m dữ liệu";
            this.gbList.GroupSummary.AddRange(new GridSummaryItem[] { new GridGroupSummaryItem(SummaryItemType.Sum, "WorkTotal", this.colWriteDate, ""), new GridGroupSummaryItem(SummaryItemType.Sum, "RealDay", this.colWriteFromDate, ""), new GridGroupSummaryItem(SummaryItemType.Sum, "RegulationDay", this.colWriteToDate, ""), new GridGroupSummaryItem(SummaryItemType.Sum, "FurloughDay", this.colRestFromDate, ""), new GridGroupSummaryItem(SummaryItemType.Sum, "CompensationDay", this.colRestToDate, "") });
            this.gbList.IndicatorWidth = 40;
            this.gbList.Name = "gbList";
            this.gbList.OptionsBehavior.AllowIncrementalSearch = true;
            this.gbList.OptionsBehavior.AutoExpandAllGroups = true;
            this.gbList.OptionsBehavior.CopyToClipboardWithColumnHeaders = false;
            this.gbList.OptionsBehavior.FocusLeaveOnTab = true;
            this.gbList.OptionsCustomization.AllowFilter = false;
            this.gbList.OptionsFilter.AllowColumnMRUFilterList = false;
            this.gbList.OptionsFilter.AllowFilterEditor = false;
            this.gbList.OptionsFilter.AllowMRUFilterList = false;
            this.gbList.OptionsLayout.StoreAllOptions = true;
            this.gbList.OptionsLayout.StoreAppearance = true;
            this.gbList.OptionsMenu.EnableColumnMenu = false;
            this.gbList.OptionsMenu.EnableGroupPanelMenu = false;
            this.gbList.OptionsNavigation.EnterMoveNextColumn = true;
            this.gbList.OptionsSelection.InvertSelection = true;
            this.gbList.OptionsSelection.MultiSelect = true;
            this.gbList.OptionsView.AllowCellMerge = true;
            this.gbList.OptionsView.ColumnAutoWidth = false;
            this.gbList.OptionsView.ShowAutoFilterRow = true;
            this.gbList.OptionsView.ShowFilterPanelMode = ShowFilterPanelMode.Never;
            this.gbList.OptionsView.ShowGroupPanel = false;
            this.gbList.CustomDrawRowIndicator += new RowIndicatorCustomDrawEventHandler(this.gbList_CustomDrawRowIndicator);
            this.gbList.KeyDown += new KeyEventHandler(this.gbList_KeyDown);
            this.gbList.MouseDown += new MouseEventHandler(this.gbList_MouseDown);
            this.gbList.DoubleClick += new EventHandler(this.gbList_DoubleClick);
            this.gbList.RowCellClick += new RowCellClickEventHandler(this.gbList_RowCellClick);
            this.gridBand2.AppearanceHeader.Options.UseTextOptions = true;
            this.gridBand2.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.gridBand2.Caption = "Th\x00f4ng tin nh\x00e2n vi\x00ean";
            this.gridBand2.Columns.Add(this.colEmployeeCode);
            this.gridBand2.Columns.Add(this.colFirstName);
            this.gridBand2.Columns.Add(this.colLastName);
            this.gridBand2.Columns.Add(this.colBranchName);
            this.gridBand2.Columns.Add(this.colDepartmentName);
            this.gridBand2.Columns.Add(this.colGroupName);
            this.gridBand2.Fixed = FixedStyle.Left;
            this.gridBand2.MinWidth = 20;
            this.gridBand2.Name = "gridBand2";
            this.gridBand2.Visible = false;
            this.gridBand2.Width = 0x47;
            this.colEmployeeCode.AppearanceHeader.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.colEmployeeCode.AppearanceHeader.Options.UseFont = true;
            this.colEmployeeCode.Caption = "M\x00e3 nh\x00e2n vi\x00ean";
            this.colEmployeeCode.FieldName = "EmployeeCode";
            this.colEmployeeCode.Name = "colEmployeeCode";
            this.colEmployeeCode.OptionsColumn.AllowEdit = false;
            this.colEmployeeCode.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colEmployeeCode.OptionsColumn.ReadOnly = true;
            this.colFirstName.AppearanceHeader.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.colFirstName.AppearanceHeader.Options.UseFont = true;
            this.colFirstName.Caption = "Họ l\x00f3t";
            this.colFirstName.FieldName = "FirstName";
            this.colFirstName.Name = "colFirstName";
            this.colFirstName.OptionsColumn.AllowEdit = false;
            this.colFirstName.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colFirstName.OptionsColumn.ReadOnly = true;
            this.colFirstName.Width = 0x7c;
            this.colLastName.AppearanceHeader.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.colLastName.AppearanceHeader.Options.UseFont = true;
            this.colLastName.Caption = "T\x00ean";
            this.colLastName.FieldName = "LastName";
            this.colLastName.Name = "colLastName";
            this.colLastName.OptionsColumn.AllowEdit = false;
            this.colLastName.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colLastName.OptionsColumn.ReadOnly = true;
            this.colLastName.Width = 0x47;
            this.colBranchName.Caption = "Chi nh\x00e1nh";
            this.colBranchName.FieldName = "BranchName";
            this.colBranchName.Name = "colBranchName";
            this.colBranchName.OptionsColumn.AllowEdit = false;
            this.colBranchName.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colBranchName.OptionsColumn.ReadOnly = true;
            this.colDepartmentName.Caption = "Ph\x00f2ng ban";
            this.colDepartmentName.FieldName = "DepartmentName";
            this.colDepartmentName.Name = "colDepartmentName";
            this.colDepartmentName.OptionsColumn.AllowEdit = false;
            this.colDepartmentName.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colDepartmentName.OptionsColumn.ReadOnly = true;
            this.colGroupName.Caption = "Tổ nh\x00f3m";
            this.colGroupName.FieldName = "GroupName";
            this.colGroupName.Name = "colGroupName";
            this.colGroupName.OptionsColumn.AllowEdit = false;
            this.colGroupName.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colGroupName.OptionsColumn.ReadOnly = true;
            this.gridBand9.Columns.Add(this.colWriteDate);
            this.gridBand9.MinWidth = 20;
            this.gridBand9.Name = "gridBand9";
            this.gridBand9.Width = 110;
            this.colWriteDate.AppearanceCell.BackColor = Color.WhiteSmoke;
            this.colWriteDate.AppearanceCell.Options.UseBackColor = true;
            this.colWriteDate.AppearanceCell.Options.UseTextOptions = true;
            this.colWriteDate.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colWriteDate.AppearanceHeader.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.colWriteDate.AppearanceHeader.ForeColor = Color.Red;
            this.colWriteDate.AppearanceHeader.Options.UseFont = true;
            this.colWriteDate.AppearanceHeader.Options.UseForeColor = true;
            this.colWriteDate.Caption = "Ng\x00e0y viết đơn";
            this.colWriteDate.FieldName = "WriteDate";
            this.colWriteDate.Name = "colWriteDate";
            this.colWriteDate.OptionsColumn.AllowEdit = false;
            this.colWriteDate.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colWriteDate.OptionsColumn.ReadOnly = true;
            this.colWriteDate.Visible = true;
            this.colWriteDate.Width = 110;
            this.gridBand3.AppearanceHeader.ForeColor = Color.DarkOliveGreen;
            this.gridBand3.AppearanceHeader.Options.UseForeColor = true;
            this.gridBand3.AppearanceHeader.Options.UseTextOptions = true;
            this.gridBand3.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.gridBand3.Caption = "Ng\x00e0y xin nghỉ";
            this.gridBand3.Columns.Add(this.colWriteFromDate);
            this.gridBand3.Columns.Add(this.colWriteToDate);
            this.gridBand3.MinWidth = 20;
            this.gridBand3.Name = "gridBand3";
            this.gridBand3.Width = 0xbc;
            this.colWriteFromDate.AppearanceCell.BackColor = Color.MintCream;
            this.colWriteFromDate.AppearanceCell.Options.UseBackColor = true;
            this.colWriteFromDate.AppearanceCell.Options.UseTextOptions = true;
            this.colWriteFromDate.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colWriteFromDate.AppearanceHeader.ForeColor = Color.DarkOliveGreen;
            this.colWriteFromDate.AppearanceHeader.Options.UseForeColor = true;
            this.colWriteFromDate.Caption = "Ng\x00e0y nghỉ từ";
            this.colWriteFromDate.FieldName = "WriteFromDate";
            this.colWriteFromDate.Name = "colWriteFromDate";
            this.colWriteFromDate.OptionsColumn.AllowEdit = false;
            this.colWriteFromDate.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colWriteFromDate.OptionsColumn.ReadOnly = true;
            this.colWriteFromDate.Visible = true;
            this.colWriteFromDate.Width = 0x5d;
            this.colWriteToDate.AppearanceCell.BackColor = Color.MintCream;
            this.colWriteToDate.AppearanceCell.Options.UseBackColor = true;
            this.colWriteToDate.AppearanceCell.Options.UseTextOptions = true;
            this.colWriteToDate.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colWriteToDate.AppearanceHeader.ForeColor = Color.DarkOliveGreen;
            this.colWriteToDate.AppearanceHeader.Options.UseForeColor = true;
            this.colWriteToDate.Caption = "Ng\x00e0y nghỉ đến";
            this.colWriteToDate.FieldName = "WriteToDate";
            this.colWriteToDate.Name = "colWriteToDate";
            this.colWriteToDate.OptionsColumn.AllowEdit = false;
            this.colWriteToDate.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colWriteToDate.OptionsColumn.ReadOnly = true;
            this.colWriteToDate.Visible = true;
            this.colWriteToDate.Width = 0x5f;
            this.gridBand5.AppearanceHeader.ForeColor = Color.Purple;
            this.gridBand5.AppearanceHeader.Options.UseForeColor = true;
            this.gridBand5.AppearanceHeader.Options.UseTextOptions = true;
            this.gridBand5.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.gridBand5.Caption = "Ng\x00e0y kh\x00f4ng t\x00ednh c\x00f4ng";
            this.gridBand5.MinWidth = 20;
            this.gridBand5.Name = "gridBand5";
            this.gridBand5.Visible = false;
            this.gridBand5.Width = 0x48;
            this.gridBand8.AppearanceHeader.ForeColor = Color.Green;
            this.gridBand8.AppearanceHeader.Options.UseForeColor = true;
            this.gridBand8.AppearanceHeader.Options.UseTextOptions = true;
            this.gridBand8.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.gridBand8.Caption = "Thời gian nghỉ thực tế";
            this.gridBand8.Columns.Add(this.colRestFromDate);
            this.gridBand8.Columns.Add(this.colRestToDate);
            this.gridBand8.MinWidth = 20;
            this.gridBand8.Name = "gridBand8";
            this.gridBand8.Width = 0xd7;
            this.colRestFromDate.AppearanceCell.BackColor = Color.MintCream;
            this.colRestFromDate.AppearanceCell.Options.UseBackColor = true;
            this.colRestFromDate.AppearanceCell.Options.UseTextOptions = true;
            this.colRestFromDate.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colRestFromDate.AppearanceHeader.ForeColor = Color.DarkOliveGreen;
            this.colRestFromDate.AppearanceHeader.Options.UseForeColor = true;
            this.colRestFromDate.Caption = "Thời gian nghỉ từ";
            this.colRestFromDate.FieldName = "RestFromDate";
            this.colRestFromDate.Name = "colRestFromDate";
            this.colRestFromDate.OptionsColumn.AllowEdit = false;
            this.colRestFromDate.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colRestFromDate.OptionsColumn.ReadOnly = true;
            this.colRestFromDate.Visible = true;
            this.colRestFromDate.Width = 0x67;
            this.colRestToDate.AppearanceCell.BackColor = Color.MintCream;
            this.colRestToDate.AppearanceCell.Options.UseBackColor = true;
            this.colRestToDate.AppearanceCell.Options.UseTextOptions = true;
            this.colRestToDate.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colRestToDate.AppearanceHeader.ForeColor = Color.DarkOliveGreen;
            this.colRestToDate.AppearanceHeader.Options.UseForeColor = true;
            this.colRestToDate.Caption = "Thời gian nghỉ đến";
            this.colRestToDate.FieldName = "RestToDate";
            this.colRestToDate.Name = "colRestToDate";
            this.colRestToDate.OptionsColumn.AllowEdit = false;
            this.colRestToDate.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colRestToDate.OptionsColumn.ReadOnly = true;
            this.colRestToDate.Visible = true;
            this.colRestToDate.Width = 0x70;
            this.gridBand7.AppearanceHeader.ForeColor = Color.Purple;
            this.gridBand7.AppearanceHeader.Options.UseForeColor = true;
            this.gridBand7.AppearanceHeader.Options.UseTextOptions = true;
            this.gridBand7.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.gridBand7.Caption = "K\x00fd hiệu/L\x00fd do nghỉ";
            this.gridBand7.Columns.Add(this.colSymbol);
            this.gridBand7.Columns.Add(this.colReason);
            this.gridBand7.MinWidth = 20;
            this.gridBand7.Name = "gridBand7";
            this.gridBand7.Width = 0xe1;
            this.colSymbol.AppearanceCell.BackColor = Color.GhostWhite;
            this.colSymbol.AppearanceCell.Options.UseBackColor = true;
            this.colSymbol.AppearanceCell.Options.UseTextOptions = true;
            this.colSymbol.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colSymbol.AppearanceHeader.ForeColor = Color.Purple;
            this.colSymbol.AppearanceHeader.Options.UseForeColor = true;
            this.colSymbol.Caption = "K\x00fd hiệu";
            this.colSymbol.FieldName = "Symbol";
            this.colSymbol.Name = "colSymbol";
            this.colSymbol.OptionsColumn.AllowEdit = false;
            this.colSymbol.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colSymbol.Visible = true;
            this.colSymbol.Width = 0x44;
            this.colReason.AppearanceCell.BackColor = Color.GhostWhite;
            this.colReason.AppearanceCell.Options.UseBackColor = true;
            this.colReason.AppearanceHeader.ForeColor = Color.Purple;
            this.colReason.AppearanceHeader.Options.UseForeColor = true;
            this.colReason.Caption = "L\x00fd do nghỉ";
            this.colReason.FieldName = "Reason";
            this.colReason.Name = "colReason";
            this.colReason.OptionsColumn.AllowEdit = false;
            this.colReason.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colReason.Visible = true;
            this.colReason.Width = 0x9d;
            this.gridBand1.AppearanceHeader.Options.UseTextOptions = true;
            this.gridBand1.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.gridBand1.Columns.Add(this.colStatus);
            this.gridBand1.Columns.Add(this.colReasonCannot);
            this.gridBand1.Columns.Add(this.colDescription);
            this.gridBand1.MinWidth = 20;
            this.gridBand1.Name = "gridBand1";
            this.gridBand1.Width = 0x224;
            this.colReasonCannot.Caption = "L\x00fd do kh\x00f4ng được duyệt";
            this.colReasonCannot.FieldName = "ReasonCannot";
            this.colReasonCannot.Name = "colReasonCannot";
            this.colReasonCannot.OptionsColumn.AllowEdit = false;
            this.colReasonCannot.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colReasonCannot.Visible = true;
            this.colReasonCannot.Width = 0xb1;
            this.colDescription.Caption = "Ghi ch\x00fa";
            this.colDescription.FieldName = "Description";
            this.colDescription.Name = "colDescription";
            this.colDescription.OptionsColumn.AllowEdit = false;
            this.colDescription.OptionsColumn.AllowMerge = DefaultBoolean.False;
            this.colDescription.OptionsColumn.ReadOnly = true;
            this.colDescription.Visible = true;
            this.colDescription.Width = 0x114;
            this.colPetitionID.Caption = "M\x00e3";
            this.colPetitionID.FieldName = "PetitionID";
            this.colPetitionID.Name = "colPetitionID";
            this.repCal.AutoHeight = false;
            this.repCal.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.repCal.Name = "repCal";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.gcList);
            base.Name = "xucPetition";
            base.Size = new Size(0x2e8, 0x1ff);
            base.Controls.SetChildIndex(base.ucToolBar, 0);
            base.Controls.SetChildIndex(this.gcList, 0);
            this.repStatus.EndInit();
            this.dm.EndInit();
            this.gcList.EndInit();
            this.gbList.EndInit();
            this.repCal.EndInit();
            base.ResumeLayout(false);
        }

        protected override void Print()
        {
            if (MyRule.IsPrint("bbiProcessPetition"))
            {
                rptListPetitionByEmployee employee;
                SYS_LOG.Insert("Đơn Xin Nghỉ Ph\x00e9p", "In");
                xfmReport report = new xfmReport("Qu\x00e1 Tr\x00ecnh Xin Nghỉ Việc");
                if (this.m_IndexKey == 0)
                {
                    employee = new rptListPetitionByEmployee(this.m_EmployeeCode);
                }
                else
                {
                    employee = new rptListPetitionByEmployee(this.m_EmployeeCode, this.m_BeginDate, this.m_EndDate);
                }
                report.ShowPrintPreview(employee);
                base.Print();
            }
        }

        private void RaiseItemSelectedEventHander(HRM_PROCESS_PETITION item)
        {
            if (this.ItemSelected != null)
            {
                this.ItemSelected(this, item);
            }
        }

        public override void ReLoad()
        {
            base.SetWaitDialogCaption("Đang nạp dữ liệu...");
            this.gcList.DataSource = new HRM_PROCESS_PETITION().GetListByEmployee(this.m_EmployeeCode);
            base.SetWaitDialogCaption("Đang nạp cấu h\x00ecnh...");
            this.gbList.ClearColumnsFilter();
            base.SetWaitDialogCaption("Đ\x00e3 xong...");
            this.DoHide();
        }

        public void SetData(string EmployeeCode)
        {
            this.m_IndexKey = 0;
            this.m_EmployeeCode = EmployeeCode;
            this.gcList.DataSource = new HRM_PROCESS_PETITION().GetListByEmployee(this.m_EmployeeCode);
        }

        public void SetData(string EmployeeCode, System.DateTime BeginDate, System.DateTime EndDate)
        {
            this.m_IndexKey = 1;
            this.m_EmployeeCode = EmployeeCode;
            this.m_BeginDate = BeginDate;
            this.m_EndDate = EndDate;
            this.gcList.DataSource = new HRM_PROCESS_PETITION().GetListByDays(this.m_EmployeeCode, BeginDate, EndDate);
        }

        protected override void SetMenu(Common.Class.RowClickEventArgs e)
        {
            object rowCellValue = this.gbList.GetRowCellValue(this.gbList.FocusedRowHandle, "PetitionID");
            base.DisableMenu(false);
            if (rowCellValue == null)
            {
                base.DisableMenu(true);
            }
            else
            {
                base.SetMenu(e);
            }
        }

        public override void SetSearch(Common.Class.RowClickEventArgs e)
        {
            if (base._search)
            {
                HRM_PROCESS_PETITION item = new HRM_PROCESS_PETITION();
                object rowCellValue = this.gbList.GetRowCellValue(base.MRowClickEventArgs.RowIndex, "PetitionID");
                if (rowCellValue != null)
                {
                    base.SetWaitDialogCaption("Đang kiểm tra dữ liệu....");
                    if (item.Get(new Guid(rowCellValue.ToString())) != "OK")
                    {
                        this.DoHide();
                        XtraMessageBox.Show("Dữ liệu kh\x00f4ng tồn tại", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        this.DoHide();
                        this.RaiseItemSelectedEventHander(item);
                    }
                }
            }
        }

        private void ucList_ListKeyDown(object sender, KeyEventArgs key)
        {
            if (key.KeyCode == Keys.F2)
            {
                if (this.gbList.RowCount != 0)
                {
                    this.Change();
                }
            }
            else if ((key.KeyCode == Keys.Control) | (key.KeyCode == Keys.E))
            {
                if (this.gbList.RowCount != 0)
                {
                    this.Change();
                }
            }
            else if (key.KeyCode == Keys.Enter)
            {
                if (this.gbList.RowCount != 0)
                {
                    this.Change();
                }
            }
            else if (key.KeyCode == Keys.F5)
            {
                this.ReLoad();
            }
            else if ((key.KeyCode == Keys.Control) | (key.KeyCode == Keys.N))
            {
                this.Add();
            }
            else if ((key.KeyCode == Keys.Control) | (key.KeyCode == Keys.T))
            {
                this.Add();
            }
        }

        public delegate void ItemSelectedEventHander(object sender, HRM_PROCESS_PETITION item);
    }
}

